#define DelPtr(o) if (nullptr != o) delete o;






#define Def_Const_Class_Set_Get_Func(ClassName, ObjName) \
private: \
	ClassName m_##ObjName##__; \
public: \
	inline const ClassName* Get##ObjName() const { \
		return &m_##ObjName##__; \
	} \
	inline void Set##ObjName(const ClassName& __obj) { \
		m_##ObjName##__ = __obj; \
	}

#define Def_Const_Struct_Set_Get_Func(StructName, ObjName) \
private: \
	StructName m_##ObjName##__; \
public: \
	inline const StructName* Get##ObjName() const { \
		return &m_##ObjName##__; \
	} \
	inline void Set##ObjName(const StructName& __obj) { \
		memcpy(&m_##ObjName##__, &__obj, sizeof(StructName)); \
	}

#define Def_Struct_Set_Get_Func(StructName, ObjName) \
private: \
	StructName m_##ObjName##__; \
public: \
	inline StructName* Get##ObjName() { \
		return &m_##ObjName##__; \
	} \
	inline void Set##ObjName(const StructName& __obj) { \
		memcpy(&m_##ObjName##__, &__obj, sizeof(StructName)); \
	}

#define Def_Real_Set_Get_Ptr_Func(ClassName, ObjName) \
private: \
	ClassName* m_##ObjName##__; \
public: \
	inline ClassName* Get##ObjName() const { \
		return m_##ObjName##__; \
	} \
	inline void Set##ObjName(ClassName* __obj) { \
		m_##ObjName##__ = __obj; \
	}

#define Def_Map_Set_Get_Ptr_Func(mapT, keyT, valuePtrT) \
private: \
	typedef mapT<keyT, valuePtrT*> Map##keyT##valuePtrT##_t; \
	Map##keyT##valuePtrT##_t m_Map##keyT##valuePtrT; \
public: \
	inline valuePtrT* Get##valuePtrT(const keyT& __k) { \
		Map##keyT##valuePtrT##_t::iterator __it = m_Map##keyT##valuePtrT.find(__k); \
		if (__it != m_Map##keyT##valuePtrT.end()) \
			return __it->second; \
		return nullptr; \
	} \
	inline void Set##valuePtrT(const keyT& __k, valuePtrT* __v) { m_Map##keyT##valuePtrT[__k] = __v; } \
	inline void Rm##valuePtrT(const keyT& __k) { m_Map##keyT##valuePtrT.erase(__k); }

#define Def_Vec_Set_Get_Val_Func(valT, funcN) \
private: \
	typedef std::vector<valT> Vec##funcN##_t; \
	Vec##funcN##_t m_Vec##funcN; \
	public: \
	inline const valT* Get##funcN(int32_t i) const { \
		if (i < (int32_t)m_Vec##funcN.size()) return &m_Vec##funcN[i]; \
		return nullptr; \
	} \
	inline void Set##funcN(int32_t i, const valT& v) { if (i < (int32_t)m_Vec##funcN.size()) m_Vec##funcN[i] = v; } \
	inline void Add##funcN(const valT& v) { m_Vec##funcN.push_back(v); }

#define Def_Protocol_Check_Init(StructName, ObjName, ObjData, ObjLen) \
	if (sizeof(StructName) != ObjLen) return; \
	StructName* ObjName = (StructName*)(ObjData);

#define QUEUE_OBJ_PTR_FUNC_INIT_1(ClassName, ObjName) \
private: \
	typedef std::queue<ClassName*>		TQue##ObjName; \
	TQue##ObjName						m_Que##ObjName; \
	ClassName* create##ObjName(); \
	\
public: \
	ClassName* get##ObjName(); \
	void set##ObjName(ClassName *__t__);

#define QUEUE_OBJ_PTR_FUNC_INIT_2(CC, ClassName, ObjName) \
	ClassName* C##CC::create##ObjName() { ClassName* tObj = new ClassName; tObj->Init();  return tObj; } \
	\
	ClassName* C##CC::get##ObjName() { \
		if (m_Que##ObjName.empty()) \
			return create##ObjName(); \
		ClassName* __t__ = m_Que##ObjName.front(); \
		m_Que##ObjName.pop(); \
		return __t__; \
	} \
	void C##CC::set##ObjName(ClassName *__t__) { if (nullptr != __t__) m_Que##ObjName.push(__t__); }

#define QUEUE_OBJ_PTR_FUNC_1(ClassName, ObjName) \
private: \
	typedef std::queue<ClassName*>		TQue##ObjName; \
	TQue##ObjName						m_Que##ObjName; \
	ClassName* create##ObjName(); \
	\
public: \
	ClassName* get##ObjName(); \
	void set##ObjName(ClassName *__t__);

#define QUEUE_OBJ_PTR_FUNC_2(CC, ClassName, ObjName) \
	ClassName* C##CC::create##ObjName() { return new ClassName; } \
	\
	ClassName* C##CC::get##ObjName() { \
		if (m_Que##ObjName.empty()) \
			return create##ObjName(); \
		ClassName* __t__ = m_Que##ObjName.front(); \
		m_Que##ObjName.pop(); \
		return __t__; \
	} \
	void C##CC::set##ObjName(ClassName *__t__) { if (nullptr != __t__) m_Que##ObjName.push(__t__); }
